from fastapi import APIRouter, Request

from applications.configs.func import render_template

util_router = APIRouter(prefix="/utils", tags=["工具管理器"])


@util_router.get("/", summary='v2ray首页', description="v2ray首页")
def index(request: Request):
    # 配置参数
    utils_list = [
        {"name": "json解析", "btnList": [{"name": "格式化", "data": "json_btn1"}, {"name": "去转义", "data": "json_btn2"}]},
        {"name": "vmess协议", "btnList": [{"name": "解析", "data": "vmess_btn1"}]},
    ]
    # 点击按钮列表
    btn_list = ["vmess_btn1", "json_btn1", "json_btn2"]
    # 全局按钮
    gold_list = [
        {"name": "清空", "data": "clear_btn"},
        {"name": "复制", "data": "copy_btn"},
    ]
    gold_btn_list = ["clear_btn", "copy_btn"]
    return render_template(request, "util/index.html", {"utils_list": utils_list, "btn_list": btn_list, "gold_list": gold_list, "gold_btn_list": gold_btn_list})